package com.atguigu.spzx.manager.service.product.impl;

import com.atguigu.spzx.manager.mapper.ProductSpecMapper;
import com.atguigu.spzx.manager.service.product.ProductSpecService;
import com.atguigu.spzx.model.entity.product.ProductSpec;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Mahone
 */
@Service
public class ProductSpecServiceImpl implements ProductSpecService {

    @Autowired
    private ProductSpecMapper productSpecMapper;

    @Override
    public PageInfo<ProductSpec> getProductSpecPageList(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<ProductSpec> productSpecList = productSpecMapper.selectProductSpecPageList();
        return new PageInfo<>(productSpecList);
    }

    @Override
    public void insertProductSpec(ProductSpec productSpec) {
        productSpecMapper.insertProductSpec(productSpec);
    }

    @Override
    public void updateProductSpecById(ProductSpec productSpec) {
        productSpecMapper.updateProductSpecById(productSpec);
    }

    @Override
    public List<ProductSpec> findAllProductSpec() {
        return productSpecMapper.selectProductSpecPageList();
    }
}
